import { listConsumable } from '@/apis/asset/common'
import type { LabelValueState } from '@/types/global'
import { ref } from 'vue'

/** 耗材模块 */
export function consumables(options?: { onSuccess?: () => void }) {
  const loading = ref(false)
  const consumableList = ref<LabelValueState[]>([])

  const getConsumableList = async () => {
    try {
      loading.value = true
      const res = await listConsumable()
      consumableList.value = res.data
      options?.onSuccess && options.onSuccess()
    } finally {
      loading.value = false
    }
  }
  return { consumableList, getConsumableList, loading }
}
